var status = -1;
var selectionLog = [];

function start() {
    action(1, 0, 0)
}

function action(mode, type, selection) {
    if (status == 0 && mode == 0) {
        cm.dispose();
        return
    }(mode == 1) ? status++ : status--;
    selectionLog[status] = selection;
    var i = -1;
    if (status <= i++) {
        cm.dispose()
    } else {
        if (status === i++) {
            cm.askMenu("我查瓦德，在帮助马修勒的工作。\r\n#b你有什么想要的物品吗？#k\r\n#L0#我想要获得称号。#l\r\n#L1#我想要获得勋章。#l", 0, 9070102)
        } else {
            var reactor = "action分支" + selectionLog[1];
            eval(reactor)(mode, type, selection, i)
        }
    }
}

function action分支0(d, c, b, a) {
    if (status <= a++) {
        if (cm.haveItem(3700334)) {
            cm.sendNormalTalk("你已经获得了#i3700334:# #t3700334#了吗？真是太厉害了！", 4, 9070102, false, true)
        } else {
            cm.sendNormalTalk("你想要#i3700334:# #t3700334#吗？嗯……", 4, 9070102, false, true)
        }
    } else {
        if (status === a++) {
            if (cm.haveItem(3700334)) {
                cm.sendNormalTalk("称号获取条件如下，\r\n\r\n#b     -仅限于18人挑战的情况\r\n     - 获得A级以上时\r\n     - 只限于第一名的一个玩家#k", 4, 9070102, true, false)
            } else {
                cm.sendNormalTalk("称号获取条件如下，\r\n\r\n#b     -仅限于18人挑战的情况\r\n     - 获得A级以上时\r\n     - 只限于第一名的一个玩家#k\r\n\r\n加油吧，继续努力总有一天你能够得到的。", 4, 9070102, true, false)
            }
        } else {
            if (status === a++) {
                cm.dispose()
            }
        }
    }
}

function action分支1(c, f, g, b) {
    if (status <= b++) {
        var e = cm.getNumberFromQuestInfo(18683, "kill");
        var a = cm.getNumberFromQuestInfo(18683, "join");
        var k = cm.getNumberFromQuestInfo(18683, "sss");
        var d = cm.getNumberFromQuestInfo(18683, "assist");
        var h = "#b这些是我能给的勋章. \r\n#k";
        if (e >= 1 && !cm.haveItem(1142878)) {
            h += "\r\n#L1##i1142878:# #t1142878# - 完成1次通关#b(" + e + "/1)#k#l"
        } else {
            h += "\r\n#i1142878:# #t1142878# - 完成1次通关#b(" + e + "/1)#k" + (cm.haveItem(1142878) ? "#r(已领取)#k" : "")
        }
        if (e >= 5 && !cm.haveItem(1142879)) {
            h += "\r\n#L2##i1142879:# #t1142879# - 完成5次通关#b(" + e + "/5)#k#l"
        } else {
            h += "\r\n#i1142879:# #t1142879# - 完成5次通关#b(" + e + "/5)#k" + (cm.haveItem(1142879) ? "#r(已领取)#k" : "")
        }
        if (e >= 100 && !cm.haveItem(1142881)) {
            h += "\r\n#L4##i1142881:# #t1142881# - 完成挑战100次#b(" + a + "/100)#k#l"
        } else {
            h += "\r\n#i1142881:# #t1142881# - 完成挑战100次#b(" + a + "/100)#k" + (cm.haveItem(1142881) ? "#r(已领取)#k" : "")
        }
        if (k >= 1 && !cm.haveItem(1142882)) {
            h += "\r\n#L5##i1142882:# #t1142882# - 完成1次SSS#b(" + k + "/1)#k#l"
        } else {
            h += "\r\n#i1142882:# #t1142882# - 完成1次SSS#b(" + k + "/1)#k" + (cm.haveItem(1142882) ? "#r(已领取)#k" : "")
        }
        if (k >= 5 && !cm.haveItem(1142883)) {
            h += "\r\n#L6##i1142883:# #t1142883# - 完成5次SSS#b(" + k + "/5)#k#l"
        } else {
            h += "\r\n#i1142883:# #t1142883# - 完成5次SSS#b(" + k + "/5)#k" + (cm.haveItem(1142883) ? "#r(已领取)#k" : "")
        }
        if (k >= 30 && !cm.haveItem(1142884)) {
            h += "\r\n#L7##i1142884:# #t1142884# - 完成30次SSS#b(" + k + "/30)#k#l"
        } else {
            h += "\r\n#i1142884:# #t1142884# - 完成30次SSS#b(" + k + "/30)#k" + (cm.haveItem(1142884) ? "#r(已领取)#k" : "")
        }
        h += "\r\n#i1142885:# #t1142885# - 被吃次数达到100次#b(0/100)#k";
        h += "\r\n#i1142886:# #t1142886# - 被抓次数达到100次#b(0/100)#k";
        if (d >= 999 && !cm.haveItem(1142887)) {
            h += "\r\n#L10##i1142887:# #t1142887# - 助攻完成999次#b(" + d + "/999)#k#l"
        } else {
            h += "\r\n#i1142887:# #t1142887# - 助攻完成999次#b(" + d + "/999)#k" + (cm.haveItem(1142887) ? "#r(已领取)#k" : "")
        }
        cm.askMenu(h, 9070102)
    } else {
        if (status === b++) {
            cm.dispose();
            if (g > 0) {
                var j = 1142877 + g;
                cm.sendOk("恭喜你！这是给与你的奖励：#b#i" + j + ":# #t" + j + "#");
                cm.gainItem(j, 1)
            }
        }
    }
};